<?php
require_once 'Artdepot/Controller/Action.php';

class ExhibitionController extends Artdepot_Controller_Action
{

    public function init()
    {
		parent::init();
    }

    public function indexAction()
    {
    	$artworkIndex = $this->_request->getParam("index",null);
    	
    	
    	$table = new Model_DbTable_Exhibition();
    	
    	//@todo what if no current exhibition returned
    	$ex = $table->getCurrentExhibition();
    	
    	$this->view->currentId = $artworkIndex;
    	
    	
    	$artwork = $ex->getArtworks();
    	$artwork->seek($artworkIndex);
    	
    	$this->view->ex = $ex;
    	$this->view->currentImage = $artwork->current();
    	$this->view->total = $artwork->count();
    	
    }

    public function pastAction()
    {
    	
    	//advertisements here
    	$adTable = new Model_DbTable_Advertisement(); 
	    $this->view->ads = $adTable->fetchAll("position = 0 and enabled = 1", "display_order ASC");
    	
        $table = new Model_DbTable_Exhibition();
        $pastEx = $table->getPastExhibition();
        $this->view->exs = $pastEx;
    }

    
    public function showAction(){
    	$exId = (int)$this->_request->getParam("id");
    	$artworkIndex = $this->_request->getParam("index", null);
    	
    	if ($exId <= 0) {
    		throw new Zend_Exception("参数错误");
    	}
    	$this->view->currentId = $artworkIndex;
    	$table = new Model_DbTable_Exhibition();
    	$ex = $table->fetchRow("id = $exId");
    	
    	$artwork = $ex->getArtworks();
    	$artwork->seek($artworkIndex);
    	
    	$this->view->ex = $ex;
    	$this->view->currentImage = $artwork->current();
    	$this->view->total = $artwork->count();
    }

    public function upcomingAction()
    {
        // action body
    }
    
   


}







